﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Markup;

namespace LogicalTreeview
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            Button b;           
            this.Loaded += new RoutedEventHandler(Window1_Loaded);
            //List<Parent> parentList = new List<Parent> (); 
            //for ( int x  = 0 ; x  < 4; x++ ) 
            //{ 
            //    Parent p = new Parent { Name= string.Format("Parent{0}" , x)} ; 
            //    for ( int y = 0 ; y < 3 ; y++ )
            //    { 
            //        Child c = new Child () { Name= "child" + y.ToString()}; 
            //        p.Children.Add ( c ) ; 
            //    }
            //    Parent p2 = new Parent();
            //    p2.Name = "children"; 
            //    p2.Children.Add(new Child() { Name = "ss2" }); 
            //    p.Children.Add(p2); 
            //    parentList.Add ( p ) ; 
            //} 
            //treeview.DataContext = parentList;                  
        }

        void Window1_Loaded(object sender, RoutedEventArgs e)
        {

          //  this.LayoutRoot.ColumnDefinitions[1].Width = new GridLength(0); 
            List<Parent> list = new List<Parent> ();
            Parent p = new Parent();
            list.Add(p); 
            TreeWalker.LogicalWalk (this.container, p );
            treeviewLogical.DataContext = list;

            List<Parent> visual = new List<Parent>();
            p = new Parent();
            TreeWalker.VisualWalk(container, p); 
            visual.Add(p);
            treeviewVisual.DataContext = visual;

            this.XAML.Text = XamlWriter.Save(container.Children[0]); 


        }
    }
}
